package com.newsproject.controller;


import com.newsproject.pojo.Result;
import com.newsproject.service.OtherPersonService;

import io.swagger.annotations.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Api(tags = "其他用户个人中心的接口")
@Controller

public class OtherPersonalController {
    @Autowired
    private OtherPersonService otherPersonService;



    @ApiOperation(value = "其他用户的主页",notes = "传递其他用户的id")
    @ApiResponses(value = {
            @ApiResponse(code = 200,message = "1.otherUserInfo 其他用户的信息\n2.posts 其他用户的文章")
    })
    @GetMapping("/redirectToPage/{otherUserId}")
    public String other(@PathVariable("otherUserId") Integer otherUserId,
                        HttpSession session,  Model model) {
       return otherPersonService.otherPersonMainPage(otherUserId, session, model);
    }

    @ApiOperation(value = "查询其他用户的粉丝列表",notes = "传递其他用户的id和页码")
    @GetMapping("/follower/{otherUserId}/{pageNum}")
    @ResponseBody
    public Result<?> otherFollowers(@PathVariable("otherUserId") Integer otherUserId,
                                 @ApiParam("页码")@PathVariable("pageNum") Integer pageNum,
                                 HttpSession session
    ) {
        return otherPersonService.findOtherFollowers(otherUserId, pageNum,session);
    }
    @ApiOperation(value = "查询其他用户的关注列表",notes = "传递其他用户的id和页码")
    @GetMapping("/followed/{otherUserId}/{pageNum}")
    @ResponseBody
    public Result<?> otherFollowings(@PathVariable("otherUserId") Integer otherUserId,
                                    @ApiParam("页码")@PathVariable("pageNum") Integer pageNum,
                                    HttpSession session
    ) {
        return otherPersonService.findOtherFollowed(otherUserId, pageNum,session);
    }

}
